package com.xxxx.mq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class Product {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(){
        String mqText = "mq is "+new Date();
        amqpTemplate.convertAndSend("mq",mqText);
        String mqTextTopic = "topic mq is "+new Date();
        amqpTemplate.convertAndSend("topic", "mqText", mqTextTopic);//topic-主题交换机的名称  mqText-routing_key  mqText-传递的值
    }


}
